﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.ETL.Domain
{
    /// <summary>
    /// 存储过程的映射
    /// </summary>
    public static class StoredProcedureMapping
    {
        public static List<Entities.DtSource> GetDataSourceListByDataTable(EtlDbContext dbContext, Guid dataTableId)
        {
            return dbContext.Database.SqlQuery<Entities.DtSource>("exec [ETL_SP_GetDataSourceListByDataTable] @DtTableId={0}", dataTableId).ToList();
        }

        public static List<Views.VDtTableColumn> GetDtTableColumnWithMapping(EtlDbContext dbContext, Guid dataTableId, Guid dataSourceId)
        {
            return dbContext.Database.SqlQuery<Views.VDtTableColumn>("exec [ETL_SP_GetDtTableColumnWithMapping] @dtTableId={0},@DtSourceId={1}", dataTableId, dataSourceId).ToList();
        }

        /// <summary>
        /// 获取数据表的列，并且连带获取映射信息
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="dataTableId"></param>
        /// <param name="dataSourceId"></param>
        /// <returns></returns>
        public static List<Views.VDtTableColumn> GetDtTableColumnAndMapping(EtlDbContext dbContext, Guid dataTableId, Guid dataSourceId)
        {
            return dbContext.Database.SqlQuery<Views.VDtTableColumn>("exec [ETL_SP_GetDtTableColumnAndMapping] @dtTableId={0},@DtSourceId={1}", dataTableId, dataSourceId).ToList();
        }
        
    }
}
